<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018\9\28 0028
 * Time: 15:03
 */

namespace app\index\interfaceIn;


use app\Lib\Exception\BlException;
use app\Lib\InterfaceIn\Api\Api;
use app\Lib\Ioc\Role\RoleManage;

class addRole extends Common implements Api
{

    /**
     * @return mixed
     * @throws BlException
     */
    public function handle()
    {
        $this->check();
        $data   = $this->param->postData;
        $result = (new RoleManage())->addRole($data);
        return $this->returnCreate($result);
    }

    /**
     * 参数验证
     * @throws BlException
     */
    public function check()
    {
        $data = $this->param->postData;
        if(empty($data['opUid'])){
            throw new BlException('操作人不能为空');
        }
//        if(empty($data['remark'])){
//            throw new BlException('备注不能为空');
//        }
//        if(empty($data['listOrder']) && $data['listOrder']!=0){
//            throw new BlException('排序不能为空');
//        }
        if(empty($data['name'])){
            throw new BlException('角色名称不能为空');
        }
        if(empty($data['roleAlias'])){
            throw new BlException('角色别称名称');
        }
        return true;
    }

}